package JDBC;
import java.sql.*;

public class BaseDAO {//连接数据库
    private final String DRIVER = "com.mysql.jdbc.Driver";
    private final String URL = "jdbc:mysql://localhost:3306/student";
    private final String USER = "root";
    private final String PWD = "952391";

    public Connection getCon() throws ClassNotFoundException, SQLException {
        //加载驱动
        Class.forName(DRIVER);
        Connection con = DriverManager.getConnection(URL, USER, PWD);
        return con;
    }

    public void close(Connection con, Statement st, ResultSet rs) throws SQLException {

        if(rs !=null) {
            rs.close();
        }
        if(st !=null) {
            st.close();
        }
        if(con !=null) {
            con.close();
        }

    }
}

